package net.barbierdereuille.android.AndroBib;

import net.barbierdereuille.android.AndroBib.AndroBib.AuthorColumn;
import net.barbierdereuille.android.AndroBib.AndroBib.StringColumn;
import android.app.ListActivity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;

public class AuthorList extends ListActivity {
	private final static String TAG = "AuthorList";
	
	private Cursor mCursor;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.d(TAG, "Creating AuthorList");
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.author_list);
		
		ContentResolver content = getContentResolver();
		
		String[] proj = { AuthorColumn._ID, AuthorColumn.NAME };
		
		mCursor = content.query(AuthorColumn.CONTENT_URI, proj, null, null, AuthorColumn.DEFAULT_SORT_ORDER);
		startManagingCursor(mCursor);
		
		String[] from = { StringColumn.NAME };
		int[] to = { R.id.authorRow };
		
    	ListAdapter keys = new SimpleCursorAdapter(this, R.layout.author_row, mCursor, from, to);
    	setListAdapter(keys);
	}

}
